<template>
    <div class="proxy-links">
        <div class="proxy-links-box">
            <div class="proxy-links-box-title">
                <p class="proxy-title-item">身份: <span>{{ dailyInfo.level === 0 ? '玩家' : '代理' }}</span></p>
                <p class="proxy-title-item">直属上级：<span class="color-primary">{{ dailyInfo.superior_name}}</span></p>
            </div>
            <div class="proxy-links-box-content">
                <div class="proxy-links-box-content-item">
                    <p class="proxy-links-box-content-item-title">{{ dailyInfo.team_money +  dailyInfo.personal_money }}</p>
                    <p class="proxy-links-box-content-item-content">总佣金</p>
                </div>
                <div class="proxy-links-flex">
                    <div class="proxy-links-box-content-item flex-1">
                        <p class="proxy-links-box-content-item-title">{{ dailyInfo.team_money }}</p>
                        <p class="proxy-links-box-content-item-content">团队佣金</p>
                    </div>
                    <div class="proxy-links-box-content-item flex-1">
                        <p class="proxy-links-box-content-item-title"> {{ dailyInfo.personal_money }}</p>
                        <p class="proxy-links-box-content-item-content">直属玩家佣金</p>
                    </div>
                </div>
                <div class="proxy-links-flex">
                    <p class="btn">领取</p>
                    <p class="btn">领取记录</p>
                </div>
            </div>
            <div class="proxy-links-box-content-mask" v-if="dailyInfo.level === 0">
                <iconpark-icon icon-id="share1" size="32" class="icon"></iconpark-icon>
                <p class="tips">升级为代理，即可获得代理佣金</p>
                <p class="btn">联系上级</p>
            </div>
        </div>

        <div class="proxy-links-box">
            <div class="proxy-links-box-title">
                <p class="proxy-title-item"><span>我的链接</span></p>
                <p class="proxy-title-item">
                    <i class="icon-share"></i>
                    <span class="color-primary" @click="onClickShare"><iconpark-icon icon-id="share1" size="14" style="margin-right: 4px;"></iconpark-icon>分享</span>
                </p>
            </div>
            <div class="proxy-links-box-content-share">
                <div class="share-code">
                    <div class="qr-code">
                        <vue-qr style="width:60px;height:60px;" :text="dailyInfo.s_link" margin="1" logoCornerRadius="2" :whiteMargin="false" logoSrc="/imgs/home/logo-2.png" :size="120"></vue-qr>
                    </div>
                    <p class="share-code-text" @click="onClickShare">点击保存</p>
                </div>

                <div class="share-link">
                    <p class="share-link-text top-link">{{ dailyInfo.s_link }} <iconpark-icon name="copy1-g203620m" @click="copyClick(dailyInfo.s_link)"></iconpark-icon> </p>
                    <p class="share-link-text mt-15 ml-8  flex-center">
                        全部下级： <span class="txt-2">{{ dailyInfo.count }}</span>人 
                        <span class="ml-15 flex-center">
                            邀请码： <span class="txt-3">{{ dailyInfo.invite_code }}</span>
                            <iconpark-icon @click="copyClick(dailyInfo.invite_code)" style="margin-left: 4px;" name="copy1-g203620m"></iconpark-icon>
                        </span> 
                    </p>
                </div>

            </div>

        </div>

        <div class="proxy-links-box">
            <div class="proxy-links-box-title">
                <p class="proxy-title-item"><span>推广教程</span></p>
                <p class="proxy-title-item"></p>
            </div>
            <div class="proxy-links-box-content-jc">
                <div class="jc-box">
                    <div class="jc-title">
                        <iconpark-icon icon-id="A1" size="1rem" style="margin-right: 4px;"></iconpark-icon>
                        代理A1
                    </div>
                    <div class="jc-content">
                        <div class="jc-content-item">
                            <p class="jc-content-item-title">
                                总业绩：<span class="jc-content-item-content">500W Vnd</span>
                            </p>

                            <p class="jc-content-item-title">
                                总佣金： <span class="jc-content-item-content">16,250 Vnd</span>
                            </p>

                        </div>

                        <div class="jc-content-item">
                            <p class="jc-content-item-title">
                                直属业绩： <span class="jc-content-item-content">20W Vnd</span>
                            </p>

                            <p class="jc-content-item-title">
                                直属佣金： <span class="jc-content-item-content">100W Vnd</span>
                            </p>

                        </div>

                        <div class="jc-content-item">
                            <p class="jc-content-item-title">
                                团队业绩： <span class="jc-content-item-content">240W Vnd</span>
                            </p>

                            <p class="jc-content-item-title">
                                团队佣金： <span class="jc-content-item-content">200W Vnd</span>
                            </p>
                        </div>
                    </div>
                </div>

                <nut-image class="mt-14" src="/imgs/proxy/p-1.png" width="174" height="70" />

                <div class="mt-14 flex-between">
                    <div class="jc-box flex-1">
                        <div class="jc-title">
                            <iconpark-icon icon-id="B" size="1rem" style="margin-right: 4px;"></iconpark-icon>
                            合伙人B1
                        </div>

                        <div class="jc-content flex-center-column">
                            <span class="jc-content-item-content">100,000,000</span>
                            <p class="jc-content-item-title">有效投注</p>
                        </div>
                    </div>

                    <div class="jc-box flex-1">
                        <div class="jc-title">
                            <iconpark-icon icon-id="B" size="1rem" style="margin-right: 4px;"></iconpark-icon>
                            直属玩家B2
                        </div>

                        <div class="jc-content flex-center-column">
                            <span class="jc-content-item-content">100,000,000</span>
                            <p class="jc-content-item-title">有效投注</p>
                        </div>
                    </div>
                </div>

                <nut-image class="mt-14" src="/imgs/proxy/p-2.png" width="174" height="70" />

                <div class="mt-14 flex-between">
                    <div class="jc-box flex-1">
                        <div class="jc-title">
                            <iconpark-icon icon-id="C" size="1rem" style="margin-right: 4px;"></iconpark-icon>
                            高级厅主C1
                        </div>

                        <div class="jc-content flex-center-column">
                            <span class="jc-content-item-content">100,000,000</span>
                            <p class="jc-content-item-title">有效投注</p>
                        </div>
                    </div>

                    <div class="jc-box flex-1">
                        <div class="jc-title">
                            <iconpark-icon icon-id="C" size="1rem" style="margin-right: 4px;"></iconpark-icon>
                            直属玩家C2
                        </div>

                        <div class="jc-content flex-center-column">
                            <span class="jc-content-item-content">100,000,000</span>
                            <p class="jc-content-item-title">有效投注</p>
                        </div>
                    </div>
                </div>

                <ProxyTxtDetail />

            </div>

        </div>
        <!-- 分享弹窗 -->
        <ShareModal v-model:visible="visible" :url="dailyInfo.s_link" />

        <Toast v-model:visible="showToast">{{ t(toast_value) }}</Toast>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
// import { formatBigNumber } from "@/utils/publicMethods";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
import { copyFn } from '@/utils/publicMethods'
import { NetPacket } from "@/netBase/NetPacket";
import PKwebsocket from "@/lolo/Ws";

import vueQr from 'vue-qr/src/packages/vue-qr.vue'
import ProxyTxtDetail from './ProxyTxtDetail.vue'
import ShareModal from './ShareModal.vue'

const toast_value = ref()
const showToast = ref(false)
const dailyInfo = ref<any>({})
const visible = ref(false)


// 分享
const onClickShare = () => {
  visible.value = true
}

// 复制
const copyClick = (data: any) => {
    console.log('复制', data)
  copyFn(data)
  showToast.value = true
  toast_value.value = 'copy_success'
}

const getDailyInfo = () => {
    // @ts-ignore
    const req = NetPacket.req_agent_link_info();
    PKwebsocket.instance.send(req, true, {
        callbackName: 'msg_notify_agent_link_info',
        callback: getDailyInfoHandle
    })
}

const getDailyInfoHandle = (data: any) => {
    console.log('代理信息', data)
    dailyInfo.value = data
}

onMounted(async () => {
    getDailyInfo()
})
</script>

<style lang="scss" scoped>
$primary-title-bg-color: #1F1F4C;
$primary-bg-color: #131232;
$button-primary-color: #FF7F00;
$button-secondary-color: #4A4A4A;

.color-primary {
    color: #5B6CFF !important;
}

.proxy-links {
    .mt-14 {
        margin-top: 14px;
        width: 100%;
    }

    .flex-1 {
        flex: 1;
    }

    .flex-center-column {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }

    .flex-center {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .flex-between {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 30px;
    }

    .proxy-links-box {
        background-color: $primary-bg-color;
        border-radius: 12px;
        overflow: hidden;
        margin-bottom: 14px;
        position: relative;
        .proxy-links-box-title {
            border-radius: 12px 12px 0 0;
            height: 36px;
            font-size: 14px;
            font-weight: 400;
            padding: 0 14px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background-color: $primary-title-bg-color;
            color: #C6C4F5;
            border-bottom: 0.5px solid #353562;

            .proxy-title-item {
                &:last-child {
                    text-align: right;
                }

                flex: 1;

                span {
                    color: #FFFFFF;
                }
            }
        }

        .proxy-links-box-content {
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            padding: 16px 14px;
            border-bottom: 0.5px solid #353562;
            background-color: $primary-bg-color;

            .proxy-links-flex {
                display: flex;
                justify-content: space-between;
                align-items: center;
                flex-direction: row;
                gap: 10px;

                .btn {
                    display: flex;
                    width: 154px;
                    height: 40px;
                    justify-content: center;
                    align-items: center;
                    flex-shrink: 0;
                    border-radius: 8px;
                    background: linear-gradient(180deg, #EC6F01 0%, #EC8C01 100%);
                    box-shadow: 0.5px 0.5px 1px 0px #FFB855 inset;
                    color: #FFF;
                    font-size: 14px;
                    font-weight: 500;

                    &:last-child {
                        background: #282747;
                        box-shadow: 0.5px 0.5px 1px 0px #4B4A6E inset;
                    }
                }
            }

            .proxy-links-box-content-item {
                text-align: center;
                border-radius: 6px;
                border: 0.5px solid #353562;
                margin-bottom: 10px;
                height: 48px !important;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;

                .proxy-links-box-content-item-title {
                    font-size: 14px;
                    color: #FFFFFF;
                }

                .proxy-links-box-content-item-content {
                    font-size: 10px;
                    color: #C6C4F5;
                }
            }

            
        }
        .proxy-links-box-content-mask {
            position: absolute;
            bottom: 0;
            left: 0;
            z-index: 99;
            width: 100%;
            height: 194px;
            border-radius: 0px 0px 12px 12px;
            background: rgba(0,0,0,.5);

            .icon {
                display: block;
                margin: 50px auto 0;
                width: 32px;
                height: 32px;
            }

            .tips {
                display: block;
                margin: 6px auto 4px;
                color: #FFF;
                font-family: "PingFang SC";
                font-size: 12px;
                font-style: normal;
                font-weight: 500;
                line-height: 18px; /* 150% */
                text-align: center;
            }
            .btn {
                display: block;
                margin: 0 auto;
                width: 110px;
                height: 36px;
                line-height: 36px;
                text-align: center;
                border-radius: 8px;
                color: #FFF;
                text-align: center;
                font-family: "PingFang SC";
                font-size: 14px;
                font-weight: 500;
                background: linear-gradient(180deg, #5567FF 0%, #9E1EFF 100%);
                box-shadow: 0.5px 0.5px 1px 0px #9B9EFF inset;
            }
        }

        .proxy-links-box-content-share {
            box-sizing: border-box;
            padding: 14px 14px 20px 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .share-code {
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                width: 80px;
                height: 100px;
                padding: 4px 4px 6px 4px;
                gap: 6px;
                border-radius: 10px;
                box-shadow: -0.213px -0.213px 0.426px 0px #2E296B inset, 0.213px 0.213px 0.426px 0px #2E296B inset;

                .qr-code {
                    border-radius: 8px 8px 2px 2px;
                    background: #31305A;
                    box-shadow: 0.2px 0.2px 0.4px 0px #515089 inset;
                    width: 72px;
                    height: 72px;
                    padding: 6px;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                }

                .share-code-text {
                    font-size: 12px;
                    font-style: normal;
                    font-weight: 500;
                    color: #C6C4F5;
                }
            }

            .share-link {
                margin-left: 12px;
                flex: 1;
                display: flex;
                align-items: start;
                justify-content: center;
                color: #FFF;
                font-size: 12px;
                font-weight: 500;
                flex-direction: column;
                .top-link {
                    border-radius: 8px;
                    background: #1D1C3C;
                    width: 231px;
                    height: 32px;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    padding: 0 8px;
                }
                .share-link-text {
                    font-size: 12px;
                    color: #C6C4F5;
                    
                    &.mt-15 {
                        margin-top: 15px;
                    }

                    &.ml-8 {
                        margin-left: 8px;
                    }

                    .txt-1 {
                        color: #C6C4F5;
                    }

                    .txt-2 {
                        color: #FFA423;
                    }

                    .txt-3 {
                        color: #FFFFFF;
                        font-weight: 500;
                        letter-spacing: -1px;
                    }

                    .ml-15 {
                        margin-left: 15px;
                    }
                }
            }
        }

        .proxy-links-box-content-jc {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 20px 14px;

            .jc-box {
                display: flex;
                flex-direction: column;
                width: 100%;
                border-radius: 8px;
            }

            .jc-title {
                display: flex;
                height: 28px;
                justify-content: center;
                align-items: center;
                color: #FFF;
                font-size: 12px;
                font-weight: 500;
                background: #352D28;
                border-radius: 8px 8px 0 0;
                .icon {
                    width: 16px;
                    height: 16px;
                    margin-right: 6px;
                }
            }

            .jc-content {
                height: 78px;
                box-sizing: border-box;
                padding: 8px;
                background-color: #18173F;
                border-radius: 0 0 8px 8px;
                .jc-content-item {
                    font-size: 12px;
                    color: #C6C4F5;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    margin-bottom: 4px;
                    .jc-content-item-content {
                        color: #FFF;
                    }
                }
            }

            
        }
    }
}
</style>